package copyengine.ui.component.button.animation.pc
{
	import flash.display.DisplayObject;
	import flash.events.MouseEvent;
	import copyengine.ui.component.button.animation.ICEButtonAnimation;
	
	public class CEButtonScaleAnimation implements ICEButtonAnimation
	{
		/**
		 * rolloverScal = normalScale * ROLL_OVER_SCAL_PERCENT;
		 * clickScal = normalScale * CLICK_SCAL_PERCENT;
		 */
		private static const ROLL_OVER_SCAL_PERCENT:Number = 1.1;
		private static const CLICK_SCAL_PERCENT:Number = 1;
		
		/**
		 * button skin maybe scaled  so need an value to remember the button initial value .
		 */
		private var normalScaleX:Number;
		private var normalScaleY:Number;
		
		protected var buttonBg:DisplayObject;
		
		public function CEButtonScaleAnimation(_args:Object = null)
		{

		}
		
		public function setTarget(_buttonBg:DisplayObject):void
		{
			buttonBg = _buttonBg;
			normalScaleX = buttonBg.scaleX;
			normalScaleY = buttonBg.scaleY;
		}
		
		public function dispose():void
		{
			buttonBg.scaleX = normalScaleX;
			buttonBg.scaleY = normalScaleY;
			buttonBg = null;
		}
		
		public function onMouseUp(e:MouseEvent):void
		{
			buttonBg.scaleX = normalScaleX * ROLL_OVER_SCAL_PERCENT;
			buttonBg.scaleY = normalScaleY * ROLL_OVER_SCAL_PERCENT;
		}
		
		public function onMouseDown(e:MouseEvent):void
		{
			buttonBg.scaleX = normalScaleX;
			buttonBg.scaleY = normalScaleY;
		}
		
		public function onMouseRollOver(e:MouseEvent):void
		{
			buttonBg.scaleX = normalScaleX * ROLL_OVER_SCAL_PERCENT;
			buttonBg.scaleY = normalScaleY * ROLL_OVER_SCAL_PERCENT;
		}
		
		public function onMouseRollOut(e:MouseEvent):void
		{
			buttonBg.scaleX = normalScaleX;
			buttonBg.scaleY = normalScaleY;
		}
	}
}